package com.paitoubing.springboot.Controller;

import com.paitoubing.springboot.bean.Users;
import com.paitoubing.springboot.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/users")
public class UsersController {
    @Autowired
    private UsersService service;

    @RequestMapping("/add")
    public Users add(Users users){
        service.add(users);
        return users;
    }

    @RequestMapping("/get")
    public Users get(Long id){
        return service.get(id);
    }

    @RequestMapping("/list")
    public List<Users> list(){
        return service.list();
    }

    @RequestMapping("/showUser")
    public Users showUser(){
        Users user = new Users();
        user.setId(new Long(1));
        user.setUsername("aaa");
        user.setUserpassword("aaa");
        return user;
    }
}
